package com.aipolice.service;

import com.aipolice.dao.DenewsDAO;
import com.aipolice.pojo.Denews;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DenewsService {

    @Autowired
    DenewsDAO denewsDAO;
    public List<Denews> list() {
        return denewsDAO.findAll();
    }


    public void delete(int id){
//        真删除
        denewsDAO.deleteById(id);
//        软删除

    }


    public void add(Denews denews){
        denewsDAO.save(denews);
    }

    public void addAndFlush(Denews denews){
        denewsDAO.saveAndFlush(denews);
    }

    public Denews find(int id){
        return denewsDAO.findById(id).get();
    }


}
